<!-- saved from url=(0022)http://internet.e-mail -->
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<title>Structured Control Expression Syntax</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<link href="../edit68k.css" rel="stylesheet" type="text/css">
</head>

<body class="text">
<p class="heading">Structured Control - Expression Syntax <br><hr noshade>
<p>When using the <b>DBloop</b>, <b>If</b>, <b>Repeat</b>, and <b>While</b>
structured control statements, the programmer must include an expression that
specifies the condition to test.&nbsp; The EASy68k assembler accepts three
different types of expressions:&nbsp; Condition Only, Relational and Compound. 
All of the conditional expressions use conditional tests which are formed by 
enclosing a two-letter condition inside angle brackets &lt;&gt;. See
<a href="#conditions">Valid Condition Codes</a> below for a complete list of 
supported conditions.</p>
<p>&nbsp;</p>
<p class="subheading">=== Condition Only ===</p>
<p>The Condition Only expression uses only a conditional 
test.&nbsp; With the Condition Only expression&nbsp;the assembler will 
insert a single branch instruction to accomplish the desired logical result. For example, the code:</p>
<p class="sourcecode">&nbsp; IF &lt;EQ&gt; THEN<br>
&nbsp;&nbsp;&nbsp; <i>code</i><br>
&nbsp;
ENDI</p>
<p>simply checks the Z bit of the CCR and runs <i><b>code</b></i> if Z is 
set. The code created by the assembler can be seen in the assembler created .L68 
file by checking the option 
&quot;Structured Expanded&quot; under the menu <a href="../OPTIONS.HTM">Options/Assembler 
Options</a> or using the assembler directive &quot;<a href="../Directives/opt.htm">OPT&nbsp;&nbsp; 
SEX</a>&quot;. The IF statement would create code that looks similar to the following:</p>
<p class="sourcecode">&nbsp; IF &lt;EQ&gt; THEN<br>
&nbsp;&nbsp;&nbsp; BNE&nbsp;&nbsp;&nbsp; .00000000<br>
&nbsp;&nbsp;&nbsp; <i>code</i><br>
&nbsp; ENDI<br>
.00000000</p>
<p>The assembler has inserted the BNE&nbsp; .00000000 instruction 
and the matching .00000000 label so the <i><b>code</b></i> inside the IF statement will only 
execute when the &lt;EQ&gt; condition is TRUE.</p>
<p>&nbsp;</p>
<p class="subheading">===Relational Expressions===</p>
<p>The Relational Expression consists of two operands
and a conditional test.&nbsp; These operands and the conditional test
are combined in the form:</p>
<p class="sourcecode">&nbsp; <i>op1</i> &lt;xx&gt; <i>op2</i></p>
<p>In this form, the expression is translated to the following when 
assembled:</p>
<p class="sourcecode">&nbsp; CMP&nbsp;&nbsp; <i>op1</i>,<i>op2</i><br>
&nbsp;
Bxx&nbsp; .LABEL</p>
<p>Only operands that are valid in a CMP instruction may be used but 
the order is not important. The assembler will arrange the operands as needed to 
create a valid CMP/Bxx instruction sequence.&nbsp; The various 
compare instructions and their legal addressing modes are listed below in Table1.&nbsp; 
The assembler will attempt to create a valid CMP/Bxx instruction sequence to implement 
the logic of the specified expression.&nbsp; For example, the expressions:</p>
<p class="sourcecode">&nbsp; if D1 &lt;gt&gt; #5 then&nbsp;&nbsp;&nbsp; or&nbsp;&nbsp;&nbsp; 
if #5 &lt;lt&gt; D1 then</p>
<p>both create the compare/branch sequence:</p>
<p class="sourcecode">&nbsp; CMP #5,D1<br>
&nbsp; BLE .label</p>
<p>The assembler will generate an error if the operands provided may not be arranged to 
construct a valid CMP instruction, as listed in Table1.</p>
<p>&nbsp;</p>
<p class="subheading">===Compound Expressions===</p>
<p>All of the structured statements except for DBloop may use compound 
expressions. Compound expressions are made up of two relational expressions 
joined by a logical operator (AND or OR).&nbsp; Each relational expression is 
evaluated to be true or false and then is AND-ed or OR-ed
to the other.&nbsp;If the result of the compound expression may be determined 
after the first relational expression is evaluated then the second expression is not evaluated. 
This is sometimes referred to as &quot;Short-Circuit&quot; evaluation.</p>
<p>A size may be specified for each relational expression making up a
compound expression.&nbsp; To do this, append the size of the first relational expression
on the directive; the second relational expression's size is appended on the logical
operator.&nbsp; For example the code:</p>
<p class="sourcecode">IF.W&nbsp;&nbsp; D3 &lt;GT&gt; NUMBER&nbsp;&nbsp; OR.L&nbsp;&nbsp;
(A2) &lt;eq&gt; D7&nbsp;&nbsp; THEN</p>
<p>causes the first comparison to be a word and the second to be a
long word.</p>
<p class="sourcecode">&nbsp;Compare Instructions and their Legal Addressing 
Modes<br>
&nbsp;Instruction&nbsp;&nbsp;
First
Operand&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
Second Operand<br>
-------------------------------------------------------<br>
&nbsp;&nbsp;&nbsp;
CMP&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;| &nbsp;&nbsp;
(All)&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; |&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Dn&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <br>
&nbsp;&nbsp;&nbsp;
CMP&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;| &nbsp;&nbsp;&nbsp;&nbsp; Dn&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp; |&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;(All)<sup>2</sup>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <br>
&nbsp;&nbsp;&nbsp; CMPA&nbsp;&nbsp;&nbsp;&nbsp; |&nbsp;&nbsp;&nbsp; 
(All)&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; |&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; An&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <br>
&nbsp;&nbsp;&nbsp; CMPA&nbsp;&nbsp;&nbsp;&nbsp;
|&nbsp; &nbsp;&nbsp;&nbsp; An&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 
|&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; (All)<sup>2</sup>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <br>
&nbsp;&nbsp;&nbsp; CMPI&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;|&nbsp; Immediate&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; |&nbsp;&nbsp; 
(Data alterable)<sup>1</sup><br>
&nbsp;&nbsp;&nbsp; CMPI&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;|(Data alterable)<sup>1</sup>&nbsp;|&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 
Immediate<sup>2</sup><br>
&nbsp;&nbsp;&nbsp; CMPM&nbsp;&nbsp;&nbsp;&nbsp;
|&nbsp;&nbsp;&nbsp; (An)+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; |&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 
(An)+&nbsp;&nbsp;&nbsp; &nbsp;
&nbsp;<br>
-------------------------------------------------------<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 
(Table1)</p>
<p><a name="conditions"></a><b>Valid Condition Codes:</b></p>
<p>The expression consists of a two-letter condition code enclosed 
in angle brackets &lt;cc&gt;. The condition codes are the same as those 
used in the Bcc instruction. The following condition codes may be used:</p>
<p class="text2">
&nbsp;&nbsp;&nbsp;&nbsp; &lt;CC&gt;&nbsp;&nbsp;&nbsp; Carry Clear<br>
&nbsp;&nbsp;&nbsp;&nbsp; &lt;CS&gt;&nbsp;&nbsp;&nbsp; Carry Set<br>
&nbsp;&nbsp;&nbsp;&nbsp; &lt;EQ&gt;&nbsp;&nbsp;&nbsp; Equal<br>
&nbsp;&nbsp;&nbsp;&nbsp; &lt;GE&gt;&nbsp;&nbsp;&nbsp; Greater or Equal<br>
&nbsp;&nbsp;&nbsp;&nbsp; &lt;GT&gt;&nbsp;&nbsp;&nbsp; Greater Than<br>
&nbsp;&nbsp;&nbsp;&nbsp; &lt;HI&gt;&nbsp;&nbsp;&nbsp; Higher (Unsigned Comparison)<br>
&nbsp;&nbsp;&nbsp;&nbsp; &lt;HS&gt;&nbsp;&nbsp;&nbsp; Higher or Same (Unsigned Comparison)<br>
&nbsp;&nbsp;&nbsp;&nbsp; &lt;LE&gt;&nbsp;&nbsp;&nbsp; Less than or Equal<br>
&nbsp;&nbsp;&nbsp;&nbsp; &lt;LO&gt;&nbsp;&nbsp;&nbsp; Lower (Unsigned Comparison)<br>
&nbsp;&nbsp;&nbsp;&nbsp; &lt;LS&gt;&nbsp;&nbsp;&nbsp; Lower or Same (Unsigned Comparison)<br>
&nbsp;&nbsp;&nbsp;&nbsp; &lt;LT&gt;&nbsp;&nbsp;&nbsp; Less Than<br>
&nbsp;&nbsp;&nbsp;&nbsp; &lt;MI&gt;&nbsp;&nbsp;&nbsp; Minus<br>
&nbsp;&nbsp;&nbsp;&nbsp; &lt;NE&gt;&nbsp;&nbsp;&nbsp; Not Equal<br>
&nbsp;&nbsp;&nbsp;&nbsp; &lt;PL&gt;&nbsp;&nbsp;&nbsp; Plus<br>
&nbsp;&nbsp;&nbsp;&nbsp; &lt;VC&gt;&nbsp;&nbsp;&nbsp; Overflow Clear<br>
&nbsp;&nbsp;&nbsp;&nbsp; &lt;VS&gt;&nbsp;&nbsp;&nbsp; Overflow Set</p>
<p>
Special case<br>
<font face="Courier New">&nbsp;&nbsp;&nbsp;&nbsp; &lt;T&gt;&nbsp;&nbsp;&nbsp; &nbsp; True (Used with While statement to 
create an infinite loop)<br>
&nbsp;&nbsp;&nbsp;&nbsp; &lt;F&gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; False (May be used in 
Unless statement to force use of DBRA.)</font></p>
<p><sup>1</sup>Data alterable - The operand must be an alterable memory location 
or register.</p>
<p><sup>2</sup>This addressing 
mode is only supported within structured control expressions. The assembler will 
rearrange the order of the operands to create a legal addressing mode.</p>
</body>
</html>